/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * consulter1.java
 *
 * Created on 10 janv. 2012, 18:33:30
 */
package bdlocale;

/**
 *
 * @author Marouane
 */
import java.sql.*;
import java.util.*;
/*import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.view.JasperViewer*/
public class consulter1 extends javax.swing.JFrame {

   
    /** Creates new form consulter1 */
    public consulter1() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jb = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jr1 = new javax.swing.JRadioButton();
        jr2 = new javax.swing.JRadioButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jl = new javax.swing.JList();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Consultation des résultats par :");

        jr1.setText("nom evenement");
        jr1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jr1ActionPerformed(evt);
            }
        });

        jr2.setText("num joueur");
        jr2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jr2ActionPerformed(evt);
            }
        });

        jl.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jlValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(jl);

        jButton1.setText("valider");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Actualiser");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(53, 53, 53)
                        .addComponent(jr1)
                        .addGap(50, 50, 50)
                        .addComponent(jr2)
                        .addGap(28, 28, 28)
                        .addComponent(jButton2))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(100, 100, 100)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(116, 116, 116)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jr1)
                    .addComponent(jr2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jr1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jr1ActionPerformed
jb.add(jr1);
if(jr1.isEnabled()) {
    jr2.setEnabled(false);
  try {
            
          Connection c = BDlocale.createConnection();
          Statement st = c.createStatement();
          ResultSet rs = st.executeQuery("select nom_evenement from evenement group by nom_evenement");
          Vector tab = new Vector();
          Vector tab1 = new Vector();

             while (rs.next()) {
              
              tab.add(rs.getString("nom_evenement"));
              
                jl.setListData(tab);
	       }
          /* ResultSet rs1 = st.executeQuery("select num_joueur from joueur");
          
             while (rs1.next()) {
                 
                tab1.add(rs1.getString("num_joueur"));
                jl.setListData(tab1);
                
	       }*/
             
             
            
        } catch (Exception ex) {
            ex.printStackTrace();        }
  
    
}
 
}//GEN-LAST:event_jr1ActionPerformed

private void jr2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jr2ActionPerformed
 jb.add(jr2);
 if(jr2.isEnabled()) {
    jr1.setEnabled(false);
  try {
            
          Connection c = BDlocale.createConnection();
          Statement st = c.createStatement();
          ResultSet rs = st.executeQuery("select nom_evenement from evenement group by nom_evenement");
          Vector tab1 = new Vector();

         
           ResultSet rs1 = st.executeQuery("select num_joueur from joueur");
          
             while (rs1.next()) {
                 
                tab1.add(rs1.getString("num_joueur"));
                jl.setListData(tab1);
                
	       }
             
             
            
        } catch (Exception ex) {
            ex.printStackTrace();        }  
    
 }
}//GEN-LAST:event_jr2ActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
      if(jr1.isEnabled()){
          
           /* JasperDesign jasperDesign = JRXmlLoader.load("c:\\stage.jrxml");
            JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

            Map<String, String> parameters = new HashMap<String, String>();
            parameters.put("bb", nn);
            //System.out.println(parameters.values());
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, c);
            // JasperExportManager.exportReportToPdfFile(jasperPrint, "D:\\impression\\les etas\\var.jrxml");
            JasperViewer.viewReport(jasperPrint, false);*/
      }
      
      else {
          /* JasperDesign jasperDesign = JRXmlLoader.load("c:\\stage.jrxml");
            JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

            Map<String, String> parameters = new HashMap<String, String>();
            parameters.put("bb", nn);
            //System.out.println(parameters.values());
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, c);
            // JasperExportManager.exportReportToPdfFile(jasperPrint, "D:\\impression\\les etas\\var.jrxml");
            JasperViewer.viewReport(jasperPrint, false);*/
      }
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
jr2.setEnabled(true);
jr1.setEnabled(true);
}//GEN-LAST:event_jButton2ActionPerformed

private void jlValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jlValueChanged
// TODO add your handling code here:
}//GEN-LAST:event_jlValueChanged

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(consulter1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(consulter1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(consulter1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(consulter1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new consulter1().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.ButtonGroup jb;
    private javax.swing.JList jl;
    private javax.swing.JRadioButton jr1;
    private javax.swing.JRadioButton jr2;
    // End of variables declaration//GEN-END:variables
}
